<?php

namespace App\Models\Wanggui;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class CustomerDepartmentKpPartyRecordModel extends BaseModel
{
    use HasFactory;

    protected $table = 'customer_department_kp_party_record';

    protected $fillable = [
        'wgNumber',
        'wgType',
        'wgName',
        'ranking',
        'assignId',
        'assignTime',
        'manageStatus',
        'projectPhase',
        'grade',
        'settle',
        'collect',
        'prefixAddress',
        'provinceCode',
        'cityCode',
        'districtCode',
        'address',
        'provinceCode',
        'cityCode',
        'districtCode',
        'followUpTime',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
    ];

    /**
     * 客户类型
     */
    const TYPE_RELATION     = 1;
    const TYPE_INTERMEDIARY = 2;
    const TYPE_INDIVIDUAL   = 3;

    const TYPE_MAPPING = [
        self::TYPE_RELATION     => '直接关系人',
        self::TYPE_INTERMEDIARY => '中介',
        self::TYPE_INDIVIDUAL   => '个体',
    ];

    /**
     * 客户标签
     */
    const LABEL_ON  = 1;
    const LABEL_OFF = 2;

    const LABEL_MAPPING = [
        self::LABEL_ON  => '达成合作',
        self::LABEL_OFF => '未达成合作',
    ];

    /**
     * 性别
     */
    const GENDER_MAN   = 1;
    const GENDER_WOMAN = 2;

    const GENDER_MAPPING = [
        self::GENDER_MAN   => '男',
        self::GENDER_WOMAN => '女',
    ];


    /**
     * 是否在职
     */
    const IS_ON_THE_JOB_ON  = 1;
    const IS_ON_THE_JOB_OFF = 2;

    const IS_ON_THE_JOB_MAPPING = [
        self::IS_ON_THE_JOB_ON  => '在职',
        self::IS_ON_THE_JOB_OFF => '离职'
    ];

    /**
     * 公司类型
     */
    const COMPANY_TYPE_INDIRECT = 1;
    const COMPANY_TYPE_DIRECT   = 2;

    const COMPANY_TYPE_MAPPING = [
        self::COMPANY_TYPE_INDIRECT => '中间服务商',
        self::COMPANY_TYPE_DIRECT   => '直接关系人'
    ];


    /**
     * 是否达成合作
     */
    const COOPERATE_ON  = 1;
    const COOPERATE_OFF = 0;

    const COOPERATE_MAPPING = [
        self::COOPERATE_ON  => '达成合作',
        self::COOPERATE_OFF => '未达成合作'
    ];


    /**
     * 关联任务
     * @return HasOne
     */
    public function siteTaskRel(): HasOne
    {
        return $this->hasOne(CustomerDepartmentTaskModel::class, 'id', 'taskId');
    }


    /**
     * 关联任务
     * @return HasMany
     */
    public function followUpLastRel(): HasMany
    {
        return $this->hasMany(CustomerDepartmentFollowUpRecordModel::class, 'kpPartyId', 'id');
    }
}
